<script type="text/javascript">
//shows/hides personal item elements; marks them as required or not
	function togglePersonal(enable, req)
	{
		//show block or not?
		if (enable) {
			document.getElementById('personal_item_row').style.display = '';
		} else {
			document.getElementById('personal_item_no').checked = true;
			document.getElementById('personal_item_row').style.display = 'none';
			return;
		}
		//if required, show just the name search and red *
		if (req) {
			document.getElementById('personal_req_mark').style.display = '';
			document.getElementById('personal_item_choice').style.display = 'none';
			document.getElementById('personal_item_owner_block').style.display = '';
			document.getElementById('personal_item_yes').checked = true;
			togglePersonalOwnerSearch();
		} else {
			document.getElementById('personal_req_mark').style.display = 'none';
			document.getElementById('personal_item_choice').style.display = '';
			togglePersonalOwner();
		}
	}		
			
	//shows/hides personal item owner search fields
	function togglePersonalOwner()
	{
		if(document.getElementById('personal_item_no').checked) {
			document.getElementById('personal_item_owner_block').style.display = 'none';
		}
		else if(document.getElementById('personal_item_yes').checked) {
			document.getElementById('personal_item_owner_block').style.display = '';
			togglePersonalOwnerSearch();
		}	
	}	
							
	//shows/hides personal item owner search fields
	function togglePersonalOwnerSearch()
	{	
		//if personal owner set
		if(document.getElementById('personal_item_owner_curr').checked) {
			document.getElementById('personal_item_owner_search').style.visibility = 'hidden';
		}
		else if(document.getElementById('personal_item_owner_new').checked) {
			document.getElementById('personal_item_owner_search').style.visibility = 'visible';
		}	
	}
</script>
<form action="index.php" method="post" id="additem_form" name="additem_form" <?php print($this->formEnctype); ?>>
	<input type="hidden" name="loan_period" value="<?php print($this->itemData['loan_period']); ?>"/>
<?php $this->getDisplayer()->displayHiddenFields($this->hiddenFields); ?>
	<script type="text/javascript">
		function handleQuirkyAjaxLibrary()
		{
			var mainForm = document.getElementById('additem_form');
			if (checkForm(mainForm)) {
				if (!mainForm.store_request || jQuery.browser.safari) {
					jQuery('#additem_form').append('<input type=\'hidden\' name=\'store_request\' value=\'Add Item\'/>');					
				}
				mainForm.submit();
			}
			return false;
		}
	</script>
<?php	if ($this->isPhysical) {	//physical items; show ILS search fields ?>
	<script type="text/javascript">
		function checkForm(frm)
		{
			var addTypeValue;
	
			for (i=0;i<frm.addType.length;i++) {
				if (frm.addType[i].checked==true)
					addTypeValue = frm.addType[i].value;
			}
		
			var alertMsg = '';
			if (frm.title.value == '') { alertMsg = alertMsg + 'Please enter a title.<br>' }
			if (addTypeValue == 'PERSONAL' && frm.selected_owner.value == '') { 
				alertMsg = alertMsg + 'Please select a personal owner.<br>'; 
			}
				
			if (alertMsg == '') {
				//submit form
				return true;
			} else {
				document.getElementById('alertMsg').innerHTML = alertMsg;				
				//do not submit form
				return false;
			}
		}
	
		//disables/enables ILS elements
		function toggleILS(enable)
		{
			var frm = document.getElementById('additem_form');
			var dspl;
			if (enable) {
				frm.searchTerm.disabled=false;
				frm.searchField.disabled=false;
				dspl = '';
			} else {
				frm.searchTerm.disabled=true;
				frm.searchField.disabled=true;				
				dspl = 'none';
			}
		
			document.getElementById('ils_search').style.display = dspl;
		}
		
		//shows/hides non-manual entry elements
		function toggleNonManual(show)
		{
			if (document.getElementById('nonman_local_control_row')) {
				if(show) {
					document.getElementById('nonman_local_control_row').style.display = '';
					document.getElementById('nonman_local_control_input').disabled = false;
				} else {
					document.getElementById('nonman_local_control_row').style.display = 'none';
					document.getElementById('nonman_local_control_input').disabled = true;
				}						
			}
				
			if (document.getElementById('man_local_control_row')) {
				if (show) {
					document.getElementById('man_local_control_row').style.display = 'none';
					document.getElementById('man_local_control_input').disabled = true;
				} else {
					document.getElementById('man_local_control_row').style.display = '';
					document.getElementById('man_local_control_input').disabled = false;
				}
			}
		}
	</script>
<?php if(array_key_exists('success', $this->itemData) && !$this->itemData['success']) { ?>
	<div class="warning">The search you provided did not match any items in the ILS.</div>
<?php } ?>
	<div class="headingCell1" style="width:25%; text-align:center;">Item Source</div>
	<table width="100%" border="0" cellpadding="3" cellspacing="0" class="borders">
		<tr bgcolor="#CCCCCC">
			<td width="20%" align="left" valign="middle">
				<input name="addType" type="radio" value="EUCLID_ITEM" onClick="toggleILS(1); togglePersonal(0,0); toggleNonManual(1);"<?php print($this->addTypeSelect['euclid']); ?>>
				<span class="strong">Library owned copy</span>
			</td>
			<td width="40%" align="left" valign="top">
				<input type="radio" name="addType" value="PERSONAL" onclick="toggleILS(1); togglePersonal(1,1); toggleNonManual(1);"<?php print($this->addTypeSelect['personal']); ?>>
				<span class="strong">Personal copy (library owns title)</span>
			</td>
			<td width="40%" align="left" valign="top">
				<input type="radio" name="addType" value="MANUAL"  onclick="toggleILS(0); togglePersonal(1, 0); toggleNonManual(0);">
				<span class="strong">Enter item manually (no library copy)</span>
			</td>
		</tr>
		<tr bgcolor="#CCCCCC" id="ils_search">
			<td colspan="2" align="left" valign="middle" bgcolor="#FFFFFF">
				<input id="searchTermFocus" name="searchTerm" type="text" size="15" value="<?php print($this->searchTerm); ?>">
				<select name="searchField">
					<option value="barcode"<?php print($this->barcodeSelect); ?>>Barcode</option>
					<option value="control"<?php print($this->controlSelect); ?>>Control Number</option>
				</select>
				 
				<input type="submit" value="Search" onclick="this.form.cmd.value='<?php print($this->cmd); ?>';" / >
			</td>
		</tr>
	</table>
		
<?php	} else if($this->isDigital) {	//digital item; show upload/url fields ?>
	<script type="text/javascript">
		function checkForm(frm) 
		{
			var alertMsg = '';
			if (frm.title.value == '') { 
				alertMsg = alertMsg + 'Please enter a title.<br>';  
			}						
		
			/*if (frm.documentType[1].checked && frm.userFile.value == '')
				alertMsg = alertMsg + 'File path is required.<br>'; 
			
			if ((frm.documentType[0].checked ||  frm.documentType[2].checked)&& frm.url.value == '')
				alertMsg = alertMsg + 'URL is required.<br>'; 							
			*/
			if((frm.documentType.value == "DOCUMENT") && (frm.userFile.value == "")) {
				alertMsg = alertMsg + "You must choose a file to upload.<br />";
			} else if((frm.documentType.value == "URL") && (frm.url.value == "")) {
				alertMsg = alertMsg + "URL is required.<br />";
			}
			if (alertMsg == '') {
				//submit form
				return true;
			} else {
				document.getElementById('alertMsg').innerHTML = alertMsg;
				//do not submit form
				return false;
			}
		}
	</script>
		
	<div class="headingCell1" style="width:25%; text-align:center;">Search</div>
	<div class="borders" style="background-color:#CCCCCC; padding:5px;">
		<input type="hidden" name="searchField" value="control" />
		<strong>Barcode:</strong>
		<input type="text" name="searchTerm" value="<?php print($this->searchTerm); ?>" />
		&nbsp; <input type="submit" value="Search" onclick="this.form.cmd.value='<?php print($this->cmd); ?>';" / >
	</div>
	<br />
		
	<div class="headingCell1" style="width:25%; text-align:center;">Item Source</div>
<?php	
	if(
		Rd_Array::keyExistsAndNotBlank('item_id', $this->itemData) 
		&& Rd_Array::keyExistsAndNotBlank('url', $this->itemData)	
	){	//if editing digital item 
?>
	<script type="text/javascript">
		var currentItemSourceOptionID;
			
		function toggleItemSourceOptions(option_id)
		{
			if (document.getElementById(currentItemSourceOptionID)) {
				document.getElementById(currentItemSourceOptionID).style.display = 'none';
			}
			if (document.getElementById(option_id)) {
				document.getElementById(option_id).style.display = '';
			}
			currentItemSourceOptionID = option_id;
		}
	</script>
		
	<div id="item_source" class="borders" style="padding:8px 8px 12px 8px; background-color:#CCCCCC;">
		<div style="overflow:auto;" class="strong">
			Current URL <small>[<a href="?cmd=viewReserve&item=<?php print($this->itemData['item_id']); ?>" target="_blank">Preview</a>]</small>: 
<?php		if($this->itemData['is_local_file']){ //local file ?>
				Local File &ndash; <em><?php print($this->itemData['url']); ?></em>
<?php		} else { //remote file - show link to everyone ?>
				<em><?php print($this->itemData['url']); ?></em>
<?php		} ?>
			</div>
			<small>
				Please note that items stored on the ReservesDirect server are access-restricted; use the Preview link to view the item.
				<br />
				To overwrite this URL, use the options below.
			</small>
			<p />
			<div>
				<input type="radio" name="documentType" value="" checked="checked" onclick="toggleItemSourceOptions('');" /> Maintain current URL &nbsp;
				<input type="radio" name="documentType" value="DOCUMENT" onclick="toggleItemSourceOptions('item_source_upload');" /> Upload new file &nbsp;
				<input type="radio" name="documentType" value="URL" onclick="toggleItemSourceOptions('item_source_link');" /> Change URL
			</div>
			<div style="margin-left:40px;">
				<div id="item_source_upload" style="display:none;">
					<input type="file" name="userFile" size="50" />
				</div>
				<div id="item_source_link" style="display:none;">
					<input name="url" type="text" size="50" value="<?php print($this->itemData['url']); ?>"/>
					<input type="button" onclick="openNewWindow(this.form.url.value, 500);" value="Preview" />
				</div>
			</div>
		</div>


<?php	} else {	//new digital item ?>		

		<table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#CCCCCC" class="borders">
			<tr>
				<td align="left" colspan="2" valign="top"> <p class="strong">MATERIAL TYPE (Pick One):</p></td>
			</tr>
			<tr>
				<script>
					function toggleDocument(formElement)
					{
						formElement.form.userFile.disabled = !formElement.checked; 
						formElement.form.url.disabled = !formElement.checked;
					}
					
					function toggleUrl(formElement)
					{
						formElement.form.url.disabled = !formElement.checked; 
						formElement.form.userFile.disabled = formElement.checked;
					}
				</script>
			<?php 
				$itemIsUpload = !$this->requestData || !Rd_Array::keyExistsAndEquals('documentType', $this->requestData, 'URL');
				$urlIsInvalid = $this->requestData 
					&& Rd_Array::keyExistsAndNotBlank('url', $this->requestData) 
					&& !Validator_Url::validate($this->requestData['url']);
			?>
				<td align="left" valign="top">
					<font color="#FF0000"><strong>*</strong></font><input type="radio" name="documentType" value="DOCUMENT" <?php print( $itemIsUpload ? 'checked="checked"' : '');?> onclick="toggleDocument(this);">&nbsp;<span class="strong">Upload &gt;&gt;</span>
				</td>
				<td align="left" valign="top"><input type="file" id="userFile" name="userFile" size="40"></td>
			</tr>
			<tr>
				<td align="left" valign="top">
					<font color="#FF0000"><strong>*</strong></font><input type="radio" name="documentType" value="URL" <?php print( !$itemIsUpload ? 'checked="checked"' : '');?> onclick="toggleUrl(this);">
					<span class="strong">URL &gt;&gt;</span>
				</td>
				<td align="left" valign="top" <?php if ($urlIsInvalid) {print('class="invalid"');} ?>>
					<input name="url" id="url" type="text" size="50"<?php 
						if ($this->requestData && Rd_Array::keyExistsAndNotBlank('url', $this->requestData)) { 
							print('value="' . htmlentities($this->requestData['url']) .'"'); 
						}
					?> <?php print($this->requestData && Rd_Array::keyExistsAndNotBlank('url', $this->requestData) ? '' : 'disabled="disabled"');?>> <?php if ($urlIsInvalid) { ?><span class="hintText">please provide a valid URL</span><?php } ?>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><font size='-2'>
					   http://www.reservesdirect.org<br/>
					   http://links.jstor.org/xxxxx<br/>
					   http://dx.doi.org/10.xxxxx
					</font>
				</td>
			</tr>
		</table>

<?php 
	} 
?>
			
<?php } else if($this->isVideo) {	//digital item; show upload/url fields ?>
	<script type="text/javascript">
		function checkForm(frm)
		{
			var alertMsg = '';
			if (frm.title.value == '') { 
				alertMsg = alertMsg + 'Please enter a title.<br>'; 
			}						
	
			if (frm.videoFile.value == '') {
				alertMsg = alertMsg + 'File path is required.<br>';
			}
			var length = frm.videoFile.value.length;
			var start = length - 4;
			var mpegStart = length - 5;
			var rmStart = length - 3;
			var mpeg = frm.videoFile.value.substring(mpegStart, length);
			var ext = frm.videoFile.value.substring(start, length);
			var rm = frm.videoFile.value.substring(rmStart, length);
			
			if (frm.author.value == '') {
				alertMsg = alertMsg + 'Writer/Director is required.<br>';
			}							
				
			switch (ext) {
				case ".flv":
				case ".3gp":
				case ".mp4":
				case ".mov":
				case ".asf":
				case ".mpg":
				case ".avi":
				case ".wmv":
				case ".dat":
				case ".m4v":
					alertMsg = alertMsg + '';
					break;
				default:
					if (mpeg == '.mpeg' || rm == '.rm') {
						alertMsg = alertMsg + '';
					} else {
						alertMsg = alertMsg + 'The file format is not a supported video format<br>';			
					}
					break;
			}
			if (alertMsg == '') {
				document.getElementById('alertMsg').innerHTML = "Your video is being uploaded.  This could take a few minutes";
				return true;
			} else {
				document.getElementById('alertMsg').innerHTML = alertMsg;
				//do not submit form
				return false;
			}
		}
	</script>
		
	<div class="borders" style="margin:10px; padding:10px; background:lightgreen; text-align:center">
		<p>The Course Reserves video service is designed to allow you to stream
		clips of video for students to access for course-related work. Please
		note the following guidelines:</p>
		<ul>
		<li>Like other material uploaded into My Course Reserves, video
		excerpts are reviewed for copyright compliance. Please review our
		video copyright guidelines.</li>
		<li>We can accept videos in many popular formats (*.flv, *.mpg, *.mov,
		*.avi, etc). </li>
		<li>Flash video (*.flv) will be posted immediately to your class and
		available to your students </li>
		<li>All other video formats will be converted to Flash before being
		made available to students. File conversion is automated; conversion
		times (time from when you upload video to when it is available to
		students) will vary based on how long the video is and how much video
		is waiting for conversion at any given time. Please be patient. You
		will receive emails when your video is accepted for processing and when it
		is complete and available for students to view</li>
		<li>Please be as complete as possible when filling in the descriptive
		fields below </li>
		</ul>
	</div>
	<div class="headingCell1" style="width:25%; text-align:center;">Upload Video</div>
	<table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#CCCCCC" class="borders">
		<tr>
			<td align="left" valign="top">
				<input type="hidden" name="documentType" value="VIDEO" />
				<font color="#FF0000"><strong>*</strong></font><span class="strong">Upload &gt;&gt;</span>
			</td>
			<td align="left" valign="top"><input type="file" name="videoFile" size="40"></td>
		</tr>
	</table>
<?php } // back to the case of all types... ?>
	<br />
<?php 
$ils = Rd_Registry::get('root:ils');
if (
	$this->isPhysical 
	&& $ils->supportsReserveRecords() 
	&& !Rd_Array::keyExistsAndNotBlank('controlKey', $this->itemData) 
	&& !Rd_Array::keyExistsAndNotBlank('item_id', $this->itemData) 
) { 
?>
	<div id="alertMsg" class="failedText">
		This item is not properly linked to <?php print($this->catalogName); ?>.  Please update the <?php print($this->catalogName); ?> Control Number.
	</div>
<?php } ?>		
		
<?php if($this->isVideo){ ?>
	<div class="headingCell1" style="width:25%; text-align:center;">Video Details</div>
<?php } else { ?>
	<div class="headingCell1" style="width:25%; text-align:center;">Item Details</div>
<?php } ?>
		
	<table width="100%" border="0" cellpadding="3" cellspacing="0" class="borders">
		<tr align="left" valign="top" id="personal_item_row">
			<td width="20%" align="right" bgcolor="#CCCCCC" class="strong">
				<span id="personal_req_mark" style="color:#FF0000;">*</span>
				Personal Copy Owner:
				<br />&nbsp;
			</td>				
			<td>
<?php
	$personal_item_choice = array('no'=>'', 'yes'=>'');
	
	if($this->selectedOwnerId) {
		$personal_item_choice['yes'] = ' checked="true"';
	}
	else {
		$personal_item_choice['no'] = ' checked="true"';
	}
?>
				<div id="personal_item_choice">
					<input type="radio" name="personal_item" id="personal_item_no" value="no"<?php print($personal_item_choice['no']); ?> onclick="togglePersonalOwner();" /> No
					&nbsp;&nbsp;
					<input type="radio" name="personal_item" id="personal_item_yes" value="Yes"<?php print($personal_item_choice['yes']); ?> onclick="togglePersonalOwner();" /> Yes
				</div>
				<div id="personal_item_owner_block">
					
<?php	if($this->selectedOwnerId){	//if there is an existing owner, give a choice of keeping him/her or picking a new one ?>

					<input type="radio" name="personal_item_owner" id="personal_item_owner_curr" value="old" checked="checked" onclick="togglePersonalOwnerSearch();" /> Current - <strong><?php print($this->selectedOwnerName); ?></strong>
					<br />
					<input type="radio" name="personal_item_owner" id="personal_item_owner_new" value="new" onclick="togglePersonalOwnerSearch();" /> New &nbsp;
						
<?php	} else {	//if not, then just assume we are searching for a new one ?>

					<input type="hidden" name="personal_item_owner" id="personal_item_owner_new" value="new" />

<?php	} ?>

					<span id="personal_item_owner_search">
<?php
		//ajax user lookup
		$mgr = new ajaxManager('lookupUser', null, null, null, null, false, array('min_user_role'=>3, 'field_id'=>'selected_owner'));
		$mgr->display();		
?>
					</span>
				</div>
			</td>
		</tr>
		<?php 
			$titleToUse = 
				$this-> requestData && Rd_Array::keyExistsAndNotBlank('title', $this->requestData)
				? $this->requestData['title']
				: $this->itemData['title'];
			$validTitle = '' != trim($titleToUse);
		
		?>
		<tr valign="middle" <?php if (!$validTitle) {print('class="invalid"'); } ?>>
			<?php if ($this->isVideo) { ?>
			<td  width="20%" align="right" bgcolor="#CCCCCC" class="strong"><font color="#FF0000"><strong>*</strong></font>Clip Title:</td>
			<?php } else { ?>
			<td  width="20%" align="right" bgcolor="#CCCCCC" class="strong"><font color="#FF0000"><strong>*</strong></font>Title:</td>
			<?php } ?>
				<td align="left"><input name="title" type="text" size="50" value="<?php 
					print( $titleToUse ); 
				?>"> <?php if (!$validTitle) { ?><span class="hintText">Please provide a title.</span> <?php } ?></td>
		</tr>
		<tr valign="middle">
			<?php if($this->isVideo){ ?>
			<td align="right" bgcolor="#CCCCCC" class="strong"><font color="#FF0000"><strong>*</strong></font>Writer/Director:</td>
			<?php } else { ?>
			<td align="right" bgcolor="#CCCCCC" class="strong"><font color="#FF0000"></font>Author/Composer:</td>
			<?php } ?>
			<td align="left"><input name="author" type="text" size="50" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('author', $this->requestData)
						? $this->requestData['author']
						: $this->itemData['author']
					); 
				?>"></td>
		</tr>
		<tr valign="middle">
			<?php if($this->isVideo){ ?>
			<td align="right" bgcolor="#CCCCCC"><span class="strong">Performer/Actor</span><span class="strong">:</span></td>
			<?php } else { ?>
			<td align="right" bgcolor="#CCCCCC"><span class="strong">Performer</span><span class="strong">:</span></td>
			<?php } ?>
			<td align="left"><input name="performer" type="text" size="50" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('performer', $this->requestData)
						? $this->requestData['performer']
						: $this->itemData['performer']
					); 
				?>"></td>
		</tr>
		<tr valign="middle">
			<?php if($this->isVideo){ ?>
			<td align="right" bgcolor="#CCCCCC"><span class="strong">Movie/Work Title:</span></td>				
			<?php } else { ?>
			<td align="right" bgcolor="#CCCCCC"><span class="strong">Book/Journal/Work Title:</span></td>
			<?php } ?>
			<td align="left"><input name="volume_title" type="text" size="50" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('volume_title', $this->requestData)
						? $this->requestData['volume_title']
						: $this->itemData['volume_title']
					); 
				?>">
		</td>
		<tr valign="middle">
			<?php if($this->isVideo){ ?>
			<td align="right" bgcolor="#CCCCCC"><div align="right"><span class="strong">Producer / Studio:</span></td>				
			<?php } else { ?>
			<td align="right" bgcolor="#CCCCCC"><div align="right"><span class="strong">Volume / Edition:</span></td>
			<?php } ?>
			<td align="left"><input name="volume_edition" type="text" size="50" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('edition', $this->requestData)
						? $this->requestData['edition']
						: $this->itemData['edition']
					); 
				?>"></td>
		</tr>
		<tr valign="middle">
			<?php if($this->isVideo) { ?>
			<td align="right" bgcolor="#CCCCCC"><span class="strong">Times:</span></td>
			<td align="left"><input name="times_pages" type="text" size="20" value="<?php print($this->itemData['times_pages']); ?>">&nbsp;to&nbsp;
			<input name="times_pages2" type="text" size="20" value="<?php print($this->itemData['times_pages2']); ?>"></td>
			<?php } else { ?>
			<td align="right" bgcolor="#CCCCCC"><span class="strong">Pages/Times:</span></td>
			<td align="left"><input name="times_pages" type="text" size="50" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('times_pages', $this->requestData)
						? $this->requestData['times_pages']
						: $this->itemData['times_pages']
					); 
				?>"></td>
				<?php if ($this->isDigital) { ?>
						<td><small>Example: pp. 336-371 and pp. 399-442 (78 of 719)</small></td> 
				<?php } ?>
			<?php } ?>
		</tr>
			<tr valign="middle">
				<?php if($this->isVideo){ ?>
				<td align="right" bgcolor="#CCCCCC"><span class="strong">Year:</span></td>				
				<?php } else { ?>
				<td align="right" bgcolor="#CCCCCC"><span class="strong">Source / Year:</span></td>
				<?php } ?>
				<td align="left"><input name="source" type="text" size="50" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('source', $this->requestData)
						? $this->requestData['source']
						: $this->itemData['source']
					); 
				?>"> </td>
			</tr>

<?php	if ($this->isDigital && $this->docTypes) {	//document icon/mime for digital items ?>
			<tr valign="middle">
				<td align="right" bgcolor="#CCCCCC"><span class="strong">Document Type Icon:</span></td>
				<td align="left">
					<select name="selectedDocIcon" onChange="document.iconImg.src = this[this.selectedIndex].value;">
<?php		foreach ($this->docTypes as $doc_type_info) { ?>
						<option value="<?php print($doc_type_info['helper_app_icon']); ?>"><?php print($doc_type_info['helper_app_name']); ?></option>
<?php		} ?>
					</select>
					<img name="iconImg" width="24" height="20" border="0" src="public/images/doc_type_icons/doctype-clear.gif">
				</td>
			</tr>		
<?php	} ?>

			<tr align="left" valign="middle">
				<td class="strong" align="right" bgcolor="#cccccc">ISBN:</td>
				<td><input name="ISBN" size="15" maxlength="15" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('ISBN', $this->requestData)
						? $this->requestData['ISBN']
						: $this->itemData['ISBN']
					); 
				?>" type="text"></td>
			</tr>
			<?php if (!$this->isVideo) { ?>
			<tr align="left" valign="middle">
				<td class="strong" align="right" bgcolor="#cccccc">ISSN:</td>
				<td><input name="ISSN" maxlength="15" size="15" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('ISSN', $this->requestData)
						? $this->requestData['ISSN']
						: $this->itemData['ISSN']
					); 
				?>" type="text"></td>
			</tr>
			<?php } ?>
			<tr align="left" valign="middle">
				<td class="strong" align="right" bgcolor="#cccccc">OCLC:</td>
				<td><input name="OCLC" maxlength="9" size="15" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('OCLC', $this->requestData)
						? $this->requestData['OCLC']
						: $this->itemData['OCLC']
					); 
				?>" type="text"></td>
			</tr>
			<tr align="left" valign="middle">
				<td class="strong" align="right" bgcolor="#cccccc">
				<?php print($this->catalogName); ?> Control Number:
				</td>
				<td><input type="text" name="local_control_key" value="<?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('local_control_key', $this->requestData)
						? $this->requestData['local_control_key']
						: $this->itemData['controlKey']
					); 
				?>" /></td>
			</tr>			

			
<?php
			//show reserve-desk/home-library select box
			if($this->libraries){
?>
			<tr align="left" valign="top">
				<td align="right" bgcolor="#CCCCCC" class="strong">Reserve Desk:</td>
				<td>
					<select name="home_library">				
<?php			
				foreach ($this->libraries as $lib) {
					$selected = ($lib->getLibraryID()==$this->itemData['home_library']) ? ' selected="selected"' : '';
?>
						<option value="<?php print($lib->getLibraryID()); ?>"<?php print($selected); ?>><?php print($lib->getLibrary());?></option>
<?php			} ?>
					</select>
			</td></tr>
<?php		
			}
			
			//give option to choose item type and to create euclid record
			$item_group_select = array('monograph'=>'', 'multimedia'=>'');
			if($this->itemData['item_group']=='MULTIMEDIA') {
				$item_group_select['multimedia'] = ' checked="true"';
			}
			else {
				$item_group_select['monograph'] = ' checked="true"';
			}
			
			
?>
<?php	if($this->isPhysical){	//auto-set item-group for electronic items ?>		
			<tr align="left" valign="bottom">
				<td align="right" bgcolor="#CCCCCC" class="strong">Item Type:</td>
				<td>
					<input type="radio" name="item_group" value="MONOGRAPH"<?php print($item_group_select['monograph']); ?> />Monograph
					&nbsp;<input type="radio" name="item_group" value="MULTIMEDIA"<?php print($item_group_select['multimedia']); ?> /> Multimedia
					<?php if('' != trim($this->itemData['controlKey'])) { ?><span style="margin-left:2em;"><?php 
						$this->getDisplayer()->displayQuickviewLink($this->itemData['controlKey'], 'Check the item type in the catalog.'); 
					?></span> 
					<?php } else { ?>
						<span style="margin-left:2em;">No control key available for link to Quickview.</span>
					<?php } ?>
				</td>
			</tr>
<?php	} else if ($this->isVideo){ ?>
			<tr align="left" valign="bottom">
				<td align="right" bgcolor="#CCCCCC" class="strong"></td>
				<td>
					<input type="hidden" name="item_group" value="VIDEO" />	
				</td>
			</tr>
				
<?php	} else { ?>			
			<tr align="left" valign="bottom">
				<td align="right" bgcolor="#CCCCCC" class="strong"></td>
				<td>
					<input type="hidden" name="item_group" value="ELECTRONIC" />	
					<?php if('' != trim($this->itemData['controlKey'])) { ?><span style="margin-left:2em;"><?php 
						$this->getDisplayer()->displayQuickviewLink($this->itemData['controlKey'], 'Check the item type in the catalog.'); 
					?></span> 
					<?php } else { ?>
						<span style="margin-left:2em;">No control key available for link to Quickview.</span>
					<?php } ?>
				</td>
			</tr>	
			
<?php	} ?>

		</table>
		
		<br />
		<?php if($this->isVideo) { ?>
		<div class="headingCell1" style="width:25%; text-align:center;">Video Notes</div>
		<?php } else { ?>
		<div class="headingCell1" style="width:25%; text-align:center;">Item Notes</div>
		<?php } ?>
		<div style="padding:8px 8px 12px 8px;" class="borders">
		
<?php	if($this->itemData['item_id']){	//if editing existing item, use AJAX notes handler ?>

		<script language="JavaScript1.2" src="public/javascript/basicAJAX.js"></script>
		<script language="JavaScript1.2" src="public/javascript/notes_ajax.js"></script>
		
		<?php $this->getDisplayer()->displayNotesBlockAJAX($this->itemData['notes'], 'item', $this->itemData['item_id'], true); ?>

<?php }	else {	//just display plain note form ?>

		<strong>Add a new note:</strong>
		<br />
        <textarea name="new_note" cols="50" rows="3"><?php 
					print( 
						$this-> requestData && Rd_Array::keyExistsAndNotBlank('new_note', $this->requestData)
						? $this->requestData['new_note']
						: ''
					); 
				?></textarea>
        <br />
        <?php 
        	$contentChecked = $this-> requestData && Rd_Array::keyExistsAndEquals('new_note_type', $this->requestData, $this->noteTypes['content']) ? ' checked="checked"' : '';
        	$staffChecked = $this-> requestData && Rd_Array::keyExistsAndEquals('new_note_type', $this->requestData, $this->noteTypes['staff']) ? ' checked="checked"' : '';
        	$copyrightChecked = $this-> requestData && Rd_Array::keyExistsAndEquals('new_note_type', $this->requestData, $this->noteTypes['copyright']) ? ' checked="checked"' : '';
        ?>
        <small>Note Type:
        <label><input type="radio" name="new_note_type" value="<?php print($this->noteTypes['content']); ?>"<?php print($contentChecked); ?>>Content Note</label>
        <label><input type="radio" name="new_note_type" value="<?php print($this->noteTypes['staff']); ?>"<?php print($staffChecked); ?>>Staff Note</label>
        <label><input type="radio" name="new_note_type" value="<?php print($this->noteTypes['copyright']); ?>"<?php print($copyrightChecked); ?>>Copyright Note</label>

<?php	} ?>
				
		</div>
				
		<br />
		<strong><font color="#FF0000">* </font></strong><span class="helperText">= required fields</span></td></tr>

		<br />
		<div style="text-align:center;"><input type="submit" name="store_request" value="Add Item" onclick="handleQuirkyAjaxLibrary();"></div>
		
</form>		
<script type="text/javascript">
<?php if($this->isPhysical){
		//if we are adding a physical item, we need to set the proper visibility defaults, based on type of item
		//we do this w/ jscript
?>
		//run some code to set up the form in the beginning
		var frm = document.getElementById('additem_form');
		var addTypeValue;
		
		for (i=0;i<frm.addType.length;i++) {
			if (frm.addType[i].checked==true)
				addTypeValue = frm.addType[i].value;
		}

		if( addTypeValue == 'MANUAL' ) {
			toggleILS(0);
			togglePersonal(1, 0);
			toggleNonManual(0);
		}
		else if( addTypeValue == 'PERSONAL' ) {
			toggleILS(1);
			togglePersonal(1, 1);
			toggleNonManual(1);
		}
		else {
			toggleILS(1);
			togglePersonal(0, 0);
			toggleNonManual(1);
		}
<?php }	else { ?>
		//run code to set up the form in the beginning
		togglePersonal(1, 0);
<?php } ?>
</script>